<?php namespace Admin\Controller; 

use Admin\Model\Brand;

class BrandController extends AuthController{
	protected $db;
	//构造函数
	public function __init()
	{
		$this->db = new Brand;
	}
	
    //获得所有品牌列表
    public function index(){
    	$data = $this->db->getAll();
       View::with('data',$data)->make();
    }
	
	
	//添加品牌
	public function add()
	{
		
		if(IS_POST){
			if($this->db->store()){
				View::success('添加品牌成功',U('index'));
			}else{
				View::error($this->db->getError());
			}
		}else{
			View::make();
		}
		
	}
	
	//修改品牌
	public function edit()
	{
		if(IS_POST){
			if($this->db->edit()){
				View::success('修改品牌成功',U('index'));
			}else{
				View::error($this->db->getError());
			}
		}else{
			$file = $this->db->one($_GET['id']);
			View::with('file',$file)->make();
		}
		
	}
	
	
	
}
